package com.jiantong.admin.model;

import io.terminus.common.model.Paging;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * Created by cao on 2017/7/7.
 */
public class PagingMz<T> implements Serializable {
    private static final long serialVersionUID = 755183539178076901L;
    private Long total; //总页数
    private Long records; // 总记录数
    private int page; //当前页
    private List<T> rows; //记录

    public PagingMz() {
    }

    public PagingMz(Long total, Long records, int page, List<T> data) {

        this.total = total;
        this.records = records;
        this.page=page;
        this.rows =data;
    }

    public List<T> getRows() {
        return this.rows;
    }

    public void setRows(List<T> data) {
        this.rows = data;
    }

    public Long getTotal() {
        return this.total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Long  getRecords()
    {
        return  this.records;
    }

    public void  setRecords(Long records)
    {
       this.records = records;
    }


    public int getPage()
    {
        return  this.page;
    }

    public  void  setPage(int page)
    {
        this.page = page;
    }

    public Boolean isEmpty() {
        return Boolean.valueOf(Objects.equals(Long.valueOf(0L), this.total) || this.rows == null || this.rows.isEmpty());
    }

    public static <T> Paging<T> empty(Class<T> clazz) {
        List<T> emptyList = Collections.emptyList();
        return new Paging(Long.valueOf(0L), emptyList);
    }

    public static <T> Paging<T> empty() {
        return new Paging(Long.valueOf(0L), Collections.emptyList());
    }
}
